package com.xyzwps.harbor.handler.validator;

import java.util.Objects;

// TODO: pattern 检查
public class CommonValidators {

    public static final ValidateFunction<String> usernameVF = Validators.sequential(
            Objects::requireNonNull,
            StringValidators.notEmpty("username cannot be EMPTY." ),
            StringValidators.notBlank("username cannot be BLANK." ),
            StringValidators.sizeRange(3, 20,
                    "username should have AT LEAST 3 letters.",
                    "username should have AT MOST 20 letters."
            )
    );

    public static final ValidateFunction<String> passwordVF = Validators.sequential(
            Objects::requireNonNull,
            StringValidators.notEmpty("password cannot be EMPTY." ),
            StringValidators.notBlank("password cannot be BLANK." ),
            StringValidators.sizeRange(8, 32,
                    "password should have AT LEAST 8 letters.",
                    "password should have AT MOST 32 letters."
            )
    );

    public static final ValidateFunction<String> vcodeVF = Validators.sequential(
            Objects::requireNonNull,
            StringValidators.notEmpty("vcode cannot be EMPTY." ),
            StringValidators.notBlank("vcode cannot be BLANK." ),
            StringValidators.sizeRange(4, 6,
                    "password should have AT LEAST 4 letters.",
                    "password should have AT MOST 6 letters."
            )
    );
}
